package com.example.shop.mapper;


import com.example.shop.entity.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface UserMapper{
    //登录验证
    @Select("SELECT * FROM user WHERE username = #{username} AND password = #{password}")
    User find(User user);
    //修改用户信息
    @Update("UPDATE user SET username = #{username},hobby = #{hobby},tel = #{tel},personality = #{personality} ,email = #{email} where id = #{id}")
    Integer update(User user);
    //删除用户
    @Delete("DELETE FROM user where id = #{id}")
    Integer delete(@Param("id") int id);
    //多条件查询
    List<User> findByMul(@Param("id") Integer id,@Param("username") String username,
                         @Param("tel") String tel,@Param("email") String email);
    //管理界面添加用户
    int InsertUser(User user);
    //分页查询
    List<User> findPage(int pageSize, int pageNum);
    //查询用户数量
    @Select("SELECT count(*) FROM user")
    int totalUser();
    //根据username查询
    @Select("SELECT * FROM user WHERE username = #{username}")
    User findByUsername(String username);
    //存储用户图片url
    @Update("UPDATE user set usertx = #{finalPath} where username = #{username}")
    int SetTxUrl(@Param("username") String username, @Param("finalPath") String finalPath);
}
